package fun.ticsmyc.nocoderTemplate;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Ticsmyc
 * @date 2020-11-25 16:10
 */
public class 二叉树输入 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        TreeNode root = createSearchTree(br);
        br.close();

        fun(root);
    }

    private static void fun(TreeNode root) {

    }


    private static void preOrder(TreeNode root){
        if(root == null) return ;
        System.out.println(root.val);
        preOrder(root.left);
        preOrder(root.right);
    }


    // 递归创建二叉树
    private static TreeNode createSearchTree(BufferedReader br) {
        try {
            String[] rawInput = br.readLine().trim().split(" ");
            int value = Integer.parseInt(rawInput[0]);
            int left = Integer.parseInt(rawInput[1]);
            int right = Integer.parseInt(rawInput[2]);

            TreeNode treeNode = new TreeNode(value);
            if (0 != left) {
                treeNode.left = createSearchTree(br);
            }
            if (0 != right) {
                treeNode.right = createSearchTree(br);
            }
            return treeNode;
        } catch (IOException e) {
            return null;
        }
    }

}

class TreeNode {
    public int val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(int value) {
        this.val = value;
        this.left = null;
        this.right = null;
    }
}
